package org.karelun.rabbit.rcp.property.tab;

import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.karelun.rabbit.graph.Shape;

public class ShapePropertySection extends BasePropertySection<Shape> {

	private Combo sourceConnectionCombo;
	
	private Combo targetConnectionCombo;
	
	private ISWTObservableValue sourceComboObserver;
	
	private ISWTObservableValue targetComboObserver;
	
	public ShapePropertySection() {
	}
	
	@Override
	protected String getSectionTitle() {
		return "Connections";
	}
	
	@Override
	protected void doCreateControl(Composite parent) {
		parent.setLayout(new GridLayout(2, true));
		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		createSourceArea(parent);
		createTargetArea(parent);
	}
	
	private void createSourceArea(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new GridLayout(2, false));
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		new Label(composite, SWT.NONE).setText("Source:");
		sourceConnectionCombo=new Combo(composite, SWT.BORDER|SWT.READ_ONLY);
		sourceConnectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		sourceComboObserver=SWTObservables.observeText(sourceConnectionCombo, SWT.Modify);
	}

	private void createTargetArea(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new GridLayout(2, false));
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		new Label(composite, SWT.NONE).setText("Target:");
		targetConnectionCombo=new Combo(composite, SWT.BORDER|SWT.READ_ONLY);
		targetConnectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		targetComboObserver=SWTObservables.observeText(targetConnectionCombo, SWT.Modify);
	}

	@Override
	protected void dataBinding() {
		Shape shape = getSelectedObject();
		
//		FeaturePath.fromList(GraphPackage.Literals.SHAPE__SOURCE_CONNECTIONS)
		
	}
}
